﻿
using System.Diagnostics;

namespace MyTest {
    /// <summary>
    /// Product 的摘要说明
    /// </summary>
    /// 
    public abstract class Product
    {
        //字段
        protected string name;  //产品名称
        protected decimal price;    //产品价格
        
        //属性
        public string Name {
            get { return name; }
            set { name = value; }
        }

        public decimal Price {
            get { return price; }
            set { price = value; }
        }

        //无参构造方法
        public Product():this("")
        {
            Debug.WriteLine("-==调用Product无参构造方法==-");
        }

        //有参构造方法
        public Product(string name) {
            this.name = name;
            Debug.WriteLine("-==调用Product带参构造方法==-");
        }

        /// <summary>
        /// 显示产品基本信息
        /// </summary>
        /// <returns></returns>
        public virtual string Show() {
            return "产品名称："+this.name+" 产品价格:"+this.price;
        }

        /// <summary>
        /// 显示产品详细信息
        /// </summary>
        /// <returns></returns>
        public abstract string ShowDetail();

        //析构方法
        ~Product() {
            Debug.WriteLine("-==调用Product的析构方法==-");
        }
    }
}